package com.by.web.controller;

import com.by.domain.vo.ResponseResult;
import com.by.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @auth wzy
 * @date 2024/1/4 9:39
 */

@RestController
public class LoginController {

    @Autowired
    private SysUserService sysUserService;

    @PostMapping("/doLogin")
    public ResponseResult login(String username, String password){
        String token = sysUserService.login(username, password);
        return new ResponseResult(HttpStatus.OK.value(),"",token);
    }

    @PostMapping("/doLogout")
    public ResponseResult doLogout(){

        sysUserService.logout();

        ResponseResult responseResult = new ResponseResult(HttpStatus.OK.value(),"登出成功");

        return responseResult;
    }
}
